import axios from 'axios'

const service = axios.create({
    baseURL: import.meta.env.VITE_APP_API_BASE_URL || '/api', // 注意这里的更改
    timeout: 5000,
    headers: {
        'Content-Type': 'application/json;charset=utf-8'
    }
})

export default {
    get(url, params = {}) {
        return service.get(url, { params }).then(res => res.data)
    },
    post(url, data = {}) {
        return service.post(url, data).then(res => res.data)
    },
    put(url, data = {}) {
        return service.put(url, data).then(res => res.data)
    },
    delete(url) {
        return service.delete(url).then(res => res.data)
    }
}